<?php
/*
 * |--------------------------------------------------------------------------
 * | API Routes，用户系统
 * |--------------------------------------------------------------------------
 * |
 * | Here is where you can register API routes for your application. These
 * | routes are loaded by the RouteServiceProvider within a group which
 * | is assigned the "api" middleware group. Enjoy building your API!
 * |
 */

//用户登录、注册 等相关操作api
Route::group([
    'prefix' => 'oauth',
    'namespace' => 'Api\Oauth'
], function () {
    //登录
    Route::post('login', 'ApiAuthController@login');
    //快速登录（通过手机验证码登录）
    Route::post('login/short', 'ApiAuthController@shortLogin');
    //注册(pc)
    Route::post('regist_pc', 'ApiAuthController@regist');
    //注册(mobile)
    Route::post('regist_mobile', 'ApiAuthController@registForMobile');
    //检测用户名是否使用
    Route::post('username_check', 'ApiAuthController@checkUsername');
    //找回密码(重置密码)
    Route::put('password', 'ApiAuthController@getbackPassword');
    //强制绑定第3方帐号
    Route::post('oauth_bound', 'ApiAuthController@boundOauth');

    //获取地理信息(省市县等)
    Route::get('district', 'ApiAuthController@getDistrict');
    //获取用户类型
    Route::get('usertype', 'ApiAuthController@getUserTypes');
    //保存用户类型
    Route::put('usertype', 'ApiAuthController@setUserType');
    //获取国际电话区号
    Route::get('country_code', 'ApiAuthController@getCountryCode');

    //短信
    Route::prefix('sms')->group(function () {
        //发送短信验证码(手机号未使用)
        Route::post('sender/mobile_notused', 'ApiSmsController@sendSmsMobileNotUsed');
        //发送短信验证码(手机号已使用)
        Route::post('sender/mobile_used', 'ApiSmsController@sendSmsMobileUsed');
        //验证短信验证码
        Route::post('check', 'ApiSmsController@checkSms');
    });

});


//登录授权下
Route::group([
    'prefix' => 'oauth/auth',
    'namespace' => 'Api\Oauth\Auth',
    'middleware' => 'oauth.user'
], function () {
    //在登录状态获取用户信息
    Route::get('user', 'ApiUserController@getUser');
    //修改密码
    Route::put('password', 'ApiUserController@changePassword');
    //设置保存用户头像
    Route::put('avatar', 'ApiUserController@setAvatar');
    //设置用户名
    Route::put('username', 'ApiUserController@setUserName');
    //设置姓名
    Route::put('name', 'ApiUserController@setName');
    //设置性别
    Route::put('sex', 'ApiUserController@setSex');
    //设置用户地理信息
    Route::put('userdistrict', 'ApiUserController@setUserDistrict');
    //绑定新手机号
    Route::put('mobile', 'ApiUserController@boundMobile');
    //获取帐号绑定的信息(手机号、微信、QQ)
    Route::get('bounds', 'ApiUserController@getBoundInfo');
    //微信(QQ)帐号解绑
    Route::put('bound', 'ApiUserController@unboundOauth');
    //腾讯图片签名
    Route::get('tencent_pic_auth', 'ApiUserController@getTencentAuth');
});


//oauth2.0实现
Route::group([
    'prefix' => 'oauth/oauth2',
    'namespace' => 'Api\Oauth\Oauth2'
], function () {
    //获取令牌（access_token）
    Route::get('accesstoken', 'ApiOauthController@getAccessToken');
    //通过令牌获取用户信息
    Route::get('user', 'ApiOauthController@getUser');
    //刷新令牌-生成新的令牌
    Route::get('accesstoken/refresh', 'ApiOauthController@refreshAccessToken');
});
